﻿
using System.Windows;
namespace Ops.Mpc.Ioc.MessageBoxServices
{
    public delegate void MessageBoxResultHandler(object sender, MessageBoxResult messageBoxResult);
    
    /// <summary>
    /// Simple default message box service that uses a system message box to show messages
    /// </summary>
    public class MessageBoxService : IMessageBoxService
    {
        #region IMessageBoxService Members

        /// <summary>
        /// Show a message box
        /// </summary>
        /// <param name="message">The message to show in the message box</param>
        /// <param name="messageBoxResultHandler">The callback handler for the message box results</param>
        public void Show(string message, MessageBoxResultHandler messageBoxResultHandler = null)
        {
            this.Show(message,string.Empty, MessageBoxButton.OK, messageBoxResultHandler);
        }

        /// <summary>
        /// Shows a message box
        /// </summary>
        /// <param name="message">The message to show in the message box</param>
        /// <param name="caption">The caption for the message box</param>
        /// <param name="messageBoxButton">The type of buttons for the message box</param>
        /// <param name="messageBoxResultHandler">The callback handler for the message box results</param>
        public void Show(string message, string caption, System.Windows.MessageBoxButton messageBoxButton, MessageBoxResultHandler messageBoxResultHandler = null)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show(message, caption, messageBoxButton);

            if (messageBoxResultHandler != null)
                messageBoxResultHandler(null, messageBoxResult);

        }

        #endregion
    }
}
